<?php

namespace app\api\controller\v1;
use app\api\validate\IDMustBePostiveINT;
use app\api\model\Theme;
use app\api\validate\IDCollection;
use app\lib\exception\ThemeException;

class ThemeController
{
    /**
     * 函数用途描述 :
     * @author: 孙洪亮
     * @URL;http://localhost/api/v1/theme?ids=1,2,3
     */
       public function getSimpleList($ids=''){
           (new IDCollection())->goCheck();
         $ids=explode(',',$ids);
         $result=Theme::with(['topicImg','headImg'])->select($ids);
         if(!$result){
             throw new ThemeException();
         }
         return $result;
       }

    /**
     * 函数用途描述 :
     * @author: 孙洪亮
     * @URL;http://localhost/api/v1/theme/1
     */
       public function getComplexOne($id){
           (new IDMustBePostiveINT())->goCheck();
         $theme= Theme::getThemeWithProduicts($id);
         if(!$theme){
             throw new ThemeException();
         }
         return $theme;
       }
}